#include <stdio.h>
#include <iostream>
#include <device_launch_parameters.h>

// gridDim.x, blockDim.x, blockIdx.x, threadIdx.x 为cuda编译器内置变量，
// gridDim.x：用来获取grid中block的数量，
// blockDim.x：block中thread的数量，
// blockIdx.x：当前线程处于grid中的第几个block，
// threadIdx.x：当前线程处于block中的第几个thread。
__global__ void kernelFunc1() {
    printf("gridDim.x=%d, blockDim.x=%d, blockIdx.x=%d, threadIdx.x=%d \n", 
        gridDim.x, blockDim.x, blockIdx.x, threadIdx.x);
}

using namespace std;

int main() {
    cout << "start cpu main..." << endl;
    kernelFunc1<<<2, 3>>>();
    cout << "waiting for device kernel function executing..." << endl;
    cudaDeviceSynchronize();
    cout << "device kernel function executed!" << endl;
    return 0;
}